/**
 * Notes: 知识库实体
 * Ver : CCMiniCloud Framework 2.0.1 ALL RIGHTS RESERVED BY cclinux0730 (wechat)
 * Date: 2024-03-10 19:20:00 
 */

const BaseProjectModel = require('../config/models_config').base_project_model;

class KnowledgeModel extends BaseProjectModel {

}

// 集合名
KnowledgeModel.CL = BaseProjectModel.C('oa_knowledge');

KnowledgeModel.DB_STRUCTURE = {
    _pid: 'string|true',
    KNOWLEDGE_ID: 'string|true',
    
    KNOWLEDGE_TITLE: 'string|true|comment=标题',
    KNOWLEDGE_CATEGORY_ID: 'string|false|comment=分类ID',
    KNOWLEDGE_TYPE: 'int|true|default=3|comment=类型：1=技术方案, 2=问题解决方案, 3=技术文档, 4=规范文档, 5=经验总结',
    KNOWLEDGE_CONTENT: 'string|true|comment=内容',
    KNOWLEDGE_TAGS: 'array|true|default=[]|comment=标签数组',
    
    KNOWLEDGE_VISIBILITY: 'int|true|default=1|comment=可见性：1=公开, 2=部门内, 3=项目组, 4=个人',
    KNOWLEDGE_VISIBLE_TO_IDS: 'array|true|default=[]|comment=可见对象ID数组（部门ID或用户ID）',
    KNOWLEDGE_STATUS: 'int|true|default=2|comment=状态：1=草稿, 2=已发布, 3=已归档',
    
    KNOWLEDGE_ATTACHMENTS: 'array|true|default=[]|comment=附件URL数组',
    KNOWLEDGE_RELATED_PROJECT_IDS: 'array|true|default=[]|comment=关联项目ID数组',
    KNOWLEDGE_RELATED_PRODUCT_IDS: 'array|true|default=[]|comment=关联产品ID数组',
    
    KNOWLEDGE_VIEW_COUNT: 'int|true|default=0|comment=查看次数',
    KNOWLEDGE_LIKE_COUNT: 'int|true|default=0|comment=点赞次数',
    KNOWLEDGE_COMMENT_COUNT: 'int|true|default=0|comment=评论次数',
    
    KNOWLEDGE_AUTHOR_ID: 'string|true|comment=作者ID',
    KNOWLEDGE_REVIEWER_ID: 'string|false|comment=审核人ID',
    KNOWLEDGE_APPROVAL_TIME: 'int|false|comment=审核时间',
    
    KNOWLEDGE_ADD_TIME: 'int|true',
    KNOWLEDGE_EDIT_TIME: 'int|true',
    KNOWLEDGE_ADD_IP: 'string|false',
    KNOWLEDGE_EDIT_IP: 'string|false',
    KNOWLEDGE_LAST_VIEW_TIME: 'int|false|comment=最后查看时间',
};

// 字段前缀
KnowledgeModel.FIELD_PREFIX = "KNOWLEDGE_";

/**
 * 类型：1=技术方案, 2=问题解决方案, 3=技术文档, 4=规范文档, 5=经验总结
 */
KnowledgeModel.TYPE = {
    SOLUTION: 1,
    PROBLEM_SOLVING: 2,
    TECHNICAL_DOC: 3,
    STANDARD_DOC: 4,
    EXPERIENCE: 5
};

KnowledgeModel.TYPE_DESC = {
    SOLUTION: '技术方案',
    PROBLEM_SOLVING: '问题解决方案',
    TECHNICAL_DOC: '技术文档',
    STANDARD_DOC: '规范文档',
    EXPERIENCE: '经验总结'
};

/**
 * 可见性：1=公开, 2=部门内, 3=项目组, 4=个人
 */
KnowledgeModel.VISIBILITY = {
    PUBLIC: 1,
    DEPARTMENT: 2,
    PROJECT: 3,
    PERSONAL: 4
};

KnowledgeModel.VISIBILITY_DESC = {
    PUBLIC: '公开',
    DEPARTMENT: '部门内',
    PROJECT: '项目组',
    PERSONAL: '个人'
};

/**
 * 状态：1=草稿, 2=已发布, 3=已归档
 */
KnowledgeModel.STATUS = {
    DRAFT: 1,
    PUBLISHED: 2,
    ARCHIVED: 3
};

KnowledgeModel.STATUS_DESC = {
    DRAFT: '草稿',
    PUBLISHED: '已发布',
    ARCHIVED: '已归档'
};

module.exports = KnowledgeModel; 